package cn.vivi.blog.controller;

import cn.vivi.blog.entity.vo.BlogVo;
import cn.vivi.blog.service.BlogService;
import cn.vivi.common.entity.Blog;
import cn.vivi.common.util.Result;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("blogs")
public class BlogController {

    @Autowired
    private BlogService blogService;

    @GetMapping("{id}")
    public Result<BlogVo> findBlogById(@PathVariable String id) {
        return Result.success(blogService.findBlogById(id));
    }

    @GetMapping("/{current}/{size}")
    public Result<Page<BlogVo>> findBlogByPage(@PathVariable long current,@PathVariable long size) {
        return Result.success(blogService.findBlogByPage(current, size));
    }

}
